﻿using System.Collections.Generic;

using VSTalk.Engine.Core.Data;

namespace VSTalk.Engine.Core.History
{
    /// <summary>
    /// History data access
    /// </summary>
    public interface IHistoryDataProvider : IDataAccess
    {
        /// <summary>
        /// Saves messages
        /// </summary>
        /// <param name="messages"></param>
        void SaveMessages(IList<StoredMessage> messages);
        
        /// <summary>
        /// Reads all client's messages
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="withJid"></param>
        /// <returns></returns>
        IList<StoredMessage> ReadMessages(string clientId, string withJid);
        
        /// <summary>
        /// Reads all client's messages since <paramref name="fromTicks"/> (not incl.)
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="withJid"></param>
        /// <param name="fromTicks"></param>
        /// <returns></returns>
        IList<StoredMessage> ReadMessages(string clientId, string withJid, long fromTicks);

        /// <summary>
        /// Reads all client's messages from <paramref name="fromTicks"/> (not incl.) to <paramref name="toTicks"/> (incl.)
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="withJid"></param>
        /// <param name="fromTicks"></param>
        /// <param name="toTicks"></param>
        /// <returns></returns>
        IList<StoredMessage> ReadMessages(string clientId, string withJid, long fromTicks, long toTicks);
        
        /// <summary>
        /// Returns first message date
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="withJid"></param>
        /// <returns></returns>
        long LatestMessageDate(string clientId, string withJid);
    }
}